package ch6;

import java.io.FileNotFoundException;
import java.io.*;
import java.io.PrintStream;
import java.util.Scanner;

public class IO {

	public static void main(String[] args) throws IOException {
		// 流重定向
		System.out.println("hello world");
		System.setOut(new PrintStream("test.txt"));
		for (int i = 1; i <= 100; i++)
			System.out.println("This is " + i);

		Scanner sc = new Scanner(new File("test.txt"));
		String s1 = sc.next();
		String s2 = sc.next();
		int s3 = sc.nextInt();
		System.out.println(s1 + "," + s2 + "," + s3);
		sc.nextLine();
		String s4 = sc.nextLine();
		System.out.println(s4);
	}

}
